package com.jt.tenant.conn;

import com.jt.tenant.app.JTApplication;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONObject;

@HttpInlet(Conn.INLET_GET_NET_DATA)
public class GetNetData extends JTAsyGet<GetNetData.Info> {

    public String token = JTApplication.jtPreferences.readToken();

    public String obdId = JTApplication.jtPreferences.readOdbID();

    public GetNetData(AsyCallBack<Info> asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected Info parser(JSONObject object) {

        JSONObject apiTYF = object.optJSONObject("apiTYF");

        JSONObject head = apiTYF.optJSONObject("head");

        Info info = new Info();

        info.msg = head.optString("msg");

        if(info.msg.equals("000")){

            JSONObject body = apiTYF.optJSONObject("body");

            info.rate = body.optString("rate");

            info.surplus = body.optString("surplus");

        }



        return info;

    }

    public static class Info {

        public String msg;

        public String rate,surplus;
    }
}
